From 0ff28d72f68c25d85fa851fc214f9478d9cb2396 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 15 Oct 2010 12:37:21 -0400 Subject: [PATCH] examples: build examples that are included in the docs We build the examples that are included in the 'getting started' chapter of the docs to prevent them from bitrotting. Also remove the awk scripts used to extract the old examples from the tutorial, since the tutorial is gone. I'm still leaving the examples themeselves in place, for possible inclusion in 'getting started' later on. --- configure.ac | 1 + examples/{Makefile => Makefile.am} | 28 ++++++------ examples/README.1ST | 41 ------------------ examples/extract.awk | 69 ------------------------------ examples/extract.sh | 30 ------------- examples/find-examples.sh | 4 -- 6 files changed, 16 insertions(+), 157 deletions(-) rename examples/{Makefile => Makefile.am} (51%) delete mode 100644 examples/README.1ST delete mode 100644 examples/extract.awk delete mode 100755 examples/extract.sh delete mode 100755 examples/find-examples.sh diff --git a/configure.ac b/configure.ac index 52f36f9f41..8a678b54af 100644 --- a/configure.ac +++ b/configure.ac @@ -1640,6 +1640,7 @@ po-properties/Makefile.in demos/Makefile demos/gtk-demo/Makefile demos/gtk-demo/geninclude.pl +examples/Makefile tests/Makefile docs/Makefile docs/reference/Makefile diff --git a/examples/Makefile b/examples/Makefile.am similarity index 51% rename from examples/Makefile rename to examples/Makefile.am index 6d54beabb2..e5a9f8d876 100644 --- a/examples/Makefile +++ b/examples/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS = arrow \ +DIST_SUBDIRS = arrow \ aspectframe \ base \ buttonbox \ @@ -28,18 +28,20 @@ SUBDIRS = arrow \ spinbutton \ statusbar \ table \ - tictactoe \ - wheelbarrow + tictactoe +# wheelbarrow -all: - list='$(SUBDIRS)'; \ - for subdir in $$list; do \ - (cd $$subdir && $(MAKE)); \ - done +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/gdk \ + -DGDK_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED \ + $(GTK_DEBUG_FLAGS) \ + $(GTK_DEP_CFLAGS) -clean: - list='$(SUBDIRS)'; \ - for subdir in $$list; do \ - (cd $$subdir && $(MAKE) clean); \ - done +LDADD = \ + $(top_builddir)/gdk/$(gdktargetlib) \ + $(top_builddir)/gtk/$(gtktargetlib) \ + $(GTK_DEP_LIBS) +bin_PROGRAMS = hello-world window-default diff --git a/examples/README.1ST b/examples/README.1ST deleted file mode 100644 index f66a60ab08..0000000000 --- a/examples/README.1ST +++ /dev/null @@ -1,41 +0,0 @@ -GTK Example Code - Tony Gale 980623 --------------------------------------------------- - -I have written an awk script to automatically extract the code -examples from the GTK Tutorial (in sgml), so they only have to be -changed in one place. - -It's called 'extract.awk', and there is a shell wrapper to invoke -it called 'extract.sh' - -It takes the following switches: - -c : Just do checking rather than output files - -f : Extract a specific file - -d : Extract file(s) to current directory - -Without the -d switch, the code will be placed in the appropriate -sub-directory. Those sub-directories will be created if they do not -exist. - -Without the -f switch, all code examples will be extracted. - -The shell wrapper assumes that the GTK Tutorial is in the -file "../docs/gtk_tut.sgml" - -It works by looking for sections of text in the tutorial surrounded -by, for example: - -/* example-start helloworld helloworld.c */ - -and - -/* example-end */ - -Where "helloworld" is the directory into which the file will be -placed (which can also be a directory spec like hello/hello1), and -"helloworld.c" is the file name for the code. - -So, the code between these lines would be extracted to the file -helloworld/helloworld.c - -It also handles replacing the sgml tag '&' with '&' diff --git a/examples/extract.awk b/examples/extract.awk deleted file mode 100644 index a1efd673c7..0000000000 --- a/examples/extract.awk +++ /dev/null @@ -1,69 +0,0 @@ -# extract - extract C source files from GTK Tutorial -# Copyright (C) Tony Gale 1998 -# Contact: gale@gtk.org -# -# Command Switches: -# -c : Just do checking rather than output files -# -f : Extract a specific file -# -d : Extract files to current directory -# -v : Verbose - -BEGIN {in_example=0; check=0; spec_example=""; do_output=0; flatten=0; verbose=0; - for (i=0 ; i < ARGC ; i++) { - if ( ARGV[i] == "-c" ) { - check = 1; - ARGV[i]=""; - } else if ( ARGV[i] == "-f" ) { - spec_example=ARGV[i+1]; - ARGV[i]=""; - ARGV[i+1]=""; - if ( length(spec_example) == 0 ) { - print "usage: -f "; - exit; - } - } else if ( ARGV[i] == "-d" ) { - flatten = 1; - ARGV[i]=""; - } else if ( ARGV[i] == "-v" ) { - verbose = 1; - ARGV[i] = ""; - } - } -} - -$2 == "example-end" && in_example == 0 { printf("\nERROR: multiple ends at line %d\n", NR) > "/dev/stderr"; - exit} -$2 == "example-end" { in_example=0; do_output=0 } - -in_example==1 && check==0 && do_output==1 { gsub(/&/, "\\&", $0); - gsub(/</, "<", $0); - gsub(/>/, ">", $0); - print $0 >file_name } - -$2 == "example-start" && in_example == 1 { printf("\nERROR: nested example at line %d\n", NR) > "/dev/stderr"; - exit} - -$2 == "example-start" { in_example=1 } - -$2 == "example-start" && check == 0 \ - { if ( (spec_example == "") || (spec_example == $4) ) { - if ( flatten == 0 ) { - if (file_name != "") - close(file_name); - file_name = sprintf("%s/%s",$3, $4); - command = sprintf("mkdir -p %s", $3); - system(command); - } else { - file_name = $4; - } - if (verbose == 1) - printf("%s\n", file_name); - do_output=1; - } - } - - -END {} - - - diff --git a/examples/extract.sh b/examples/extract.sh deleted file mode 100755 index e7536a929f..0000000000 --- a/examples/extract.sh +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh -# extract - extract C source files from GTK Tutorial -# Copyright (C) Tony Gale 1998 -# Contact: gale@gtk.org -# -# extract.awk command Switches: -# -c : Just do checking rather than output files -# -f : Extract a specific file -# -d : Extract files to current directory - -TUTORIAL=../docs/tutorial/gtk-tut.sgml - -if [ -x /usr/bin/gawk ]; then - gawk -f extract.awk $TUTORIAL $1 $2 $3 $4 $5 -else - if [ -x /usr/bin/nawk ]; then - nawk -f extract.awk $TUTORIAL $1 $2 $3 $4 $5 - else - if [ -x /usr/bin/awk ]; then - awk -f extract.awk $TUTORIAL $1 $2 $3 $4 $5 - else - if [ -x /bin/awk ]; then - awk -f extract.awk $TUTORIAL $1 $2 $3 $4 $5 - else - echo "Can't find awk... please edit extract.sh by hand" - fi - fi - fi -fi - diff --git a/examples/find-examples.sh b/examples/find-examples.sh deleted file mode 100755 index 51de23f88c..0000000000 --- a/examples/find-examples.sh +++ /dev/null @@ -1,4 +0,0 @@ -find . -name CVS -prune -o \ - -not \( -type d -o -name Makefile.am -o -name find-examples.sh \) -print | - sed 's%\./\(.*\)% examples/\1 \\%' -echo " examples/find-examples.sh" -- 2.30.2